package com.nefu.softlab.xjwc.service;

import com.nefu.softlab.xjwc.model.Document;
import com.nefu.softlab.xjwc.utils.JSONResult;
import com.nefu.softlab.xjwc.utils.XJWCException;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author LiXiwen
 * @date 2020/2/8 11:24
 */
public interface DocumentService {
    /**
     * 上传文件
     * @return
     * @throws XJWCException
     * @param files
     * @param document
     */
    JSONResult uploadDocument(MultipartFile[] files, Document document) throws XJWCException;

    /**
     * 更新文件
     * @param files
     * @param document
     * @return
     * @throws XJWCException
     */
    String updateDocument(MultipartFile[] files, Document document);

    /**
     * 下载文件
     * @param projectId
     * @param name
     * @param response
     * @param request
     * @return
     * @throws XJWCException
     */
    String downloadDocument(Integer projectId, String name, HttpServletResponse response, HttpServletRequest request) throws XJWCException;

    /**
     * 查询该项目文件名称
     * @param projectId
     * @return
     */
    JSONResult getFileName(Integer projectId) throws XJWCException;

    /**
     * 删除文件
     * @param projectId
     * @param path
     * @return
     * @throws XJWCException
     */
    JSONResult deleteDocument(Integer projectId, String path) throws XJWCException;

    /**
     * 预览文件
     * @param projectId
     * @return
     */
    Map<String, Object> previewFiles(Integer projectId);

    /**
     * 根据活动id更新所有doc_name
     * @param oldDir
     * @param newDir
     * @param activityId
     * @return
     */
    boolean updateDocName(String oldDir, String newDir, Integer activityId);

    /**
     * 根据活动id删除所有文件
     * @param activityId
     * @return
     */
    boolean deleteDocumentsByActivityId(Integer activityId);
}
